import React, { useState, useEffect } from 'react';

import ScaleTrainingSuggest from '@/components/Scale/ScaleTrainingSuggest';

import { getPhysiquePatientInfo } from '@/pages/MedicalExamination/HealthCheckup/service';
import { getPatientInfoSingle } from '@/pages/Patriarch/ChildrenRecord/service';

import Result from '@/pages/Assessment/EvaluationCourses/components/Result';

const Page = ({ location }) => {
  const [user, setUser] = useState();

  const queryUser = async () => {
    console.log('location', location);
    const { patientId } = location.query;
    // const sub = await getPhysiquePatientInfo({ code });
    const res = await getPatientInfoSingle({ patientId });
    setUser(res);
  };

  useEffect(() => {
    // 帶出個人資訊
    queryUser();
  }, []);

  return (
    <div>
      {user && (
        <>
          <ScaleTrainingSuggest user={user} />
          {
            // 要把需要顯示的元件擷取出來.不能有輸入
          }
          <Result user={user} readonly />
        </>
      )}
    </div>
  );
};

export default Page;
